﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using BeatEmUp.Characters;
using Microsoft.Xna.Framework;

namespace BeatEmUp.Movement
{
    abstract class MovementAbstr
    {
        protected int move;
       
        public MovementAbstr(Rectangle rectangle)
        {
            position = rectangle;
            FaceDirection = FaceDirectionEnum.Right;
        }
         public FaceDirectionEnum FaceDirection
        {
            get;
            set;
        }
        protected Rectangle position;

        protected void Move(MoveEnum mov)
        {
            Rectangle newPosition = new Rectangle(position.X, position.Y, position.Width, position.Height);
            FaceDirectionEnum newFaceDirection = FaceDirection;

            switch (mov)
            {
                case MoveEnum.Up:
                    {
                        newPosition.Y -= move;
                    }
                    break;
                case MoveEnum.Down:
                    {
                        newPosition.Y += move;
                    }

                    break;
                case MoveEnum.Left:
                    {
                        newPosition.X -= move;
                        newFaceDirection = FaceDirectionEnum.Left;
                    }
                    break;
                case MoveEnum.Right:
                    {
                        newPosition.X += move;
                        newFaceDirection = FaceDirectionEnum.Right;
                    }
                    break;
            }

            if (CollisionManager.IsPositionValid(newPosition))
            {
                position = newPosition;
                FaceDirection = newFaceDirection;
            }
        }

        public Rectangle Position
        {
            get { return position; }
            set { position = value; }
        }

    }
}
